<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.fick.hibernate.model.*"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@ page import="java.util.*"  %>
<%@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="FCK"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>信息修改</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE1 {font-size: 12px;}
.STYLE4 {
	font-size: 12px;
	color: #1F4A65;
	font-weight: bold;
}

a:link {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;

}
a:visited {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;
}
a:hover {
	font-size: 12px;
	color: #FF0000;
	text-decoration: underline;
}
a:active {
	font-size: 12px;
	color: #FF0000;
	text-decoration: none;
}
.STYLE7 {font-size: 12px;}

</style>
<script type="text/javascript" src="meihuaxue.js"></script>
<script type="text/javascript" src="js/datecontrol.js"></script>
<script type="text/javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js" defer="defer"></script>
<script type="text/javascript">

  function showlayer()   {  
     var mylayer = document.getElementById("tress");
     mylayer.style.left   =   event.clientX;   
     mylayer.style.top   =   event.clientY;  
           if   (mylayer.style.visibility=="hidden")   
             {   
                 mylayer.style.visibility="visible";     
             }   
            else   mylayer.style.visibility="hidden";   
          } 
          //得到栏目的名字和ID
          function sa(channelid,lanmuName){
             showlayer();
             document.getElementById("lanmuName").value=lanmuName;
             document.getElementById("channelid").value=channelid;
          }
          function CheckForm() {
	if(document.form1.lanmuName.value=="")
	{
		alert("新闻栏目不能为空！");
		document.form1.lanmuName.focus();
		return false;
	}
	if(document.form1.newName.value=="")
	{
		alert("新闻名称不能为空！");
		document.form1.newName.focus();
		return false;
	}
	if(document.form1.shr.value=="")
	{
		alert("审核人不能为空！");
		document.form1.newName.focus();
		return false;
	}
	if(document.form1.fbr.value=="")
	{
		alert("发布人不能为空！");
		document.form1.newName.focus();
		return false;
	}
	upload.form1.submit();
	return false;

}
</script>
</head>
	<div id="tress"
		style="border: 1px solid #FF9999; width: 200px; background-color: #FFFFFF; visibility: hidden; position: absolute">
		<%Admin admin=(Admin)request.getSession().getAttribute("admin");
		ChannelDAO channeldao=new ChannelDAO();
		if (admin.getRole().getId() == 3 || admin.getRole().getId() == 5 ) {
		%>
		<script type="text/javascript">
                     var tree = new MzTreeView("tree");
                     tree.setIconPath("TreeView/"); //可用相对路
                     tree.nodes["0_1"] = "text:栏目管理;";
					 <%
					 List channellist=channeldao.findAll();
					 for(int i=0;i<channellist.size();i++)
					 {Channel channel=(Channel)channellist.get(i);

					 %> 
					  
					   tree.nodes["<%=channel.getFatherId()%>_<%=channel.getChannelId()%>"] = "text:<%=channel.getName().replaceAll("'","‘").replaceAll("\"","”")%>;method:sa('<%=channel.getChannelId()%>','<%=channel.getName().replaceAll("'","‘").replaceAll("\"","”")%>')";  
					 <%
					   }
					 %>
					 
				   tree.setTarget("MzMain");
				   document.write(tree.toString());    //亦可用 obj.innerHTML = tree.toString();
				 </script>
             <%}else{%>
                <script type="text/javascript">
                     var tree = new MzTreeView("tree");
                     tree.setIconPath("TreeView/"); //可用相对路
                     tree.nodes["0_1"] = "text:栏目管理;";
					 <%
					List channellist=new ArrayList();
					 String hql="from AdminQx where admin.adminId='"+admin.getAdminId()+"'";
					 List qxlist=new AdminQxDAO().getSession().createQuery(hql).list();
					 for(int j=0;j<qxlist.size();j++)
					 {
						 AdminQx qx=(AdminQx)qxlist.get(j);
						 channellist.add(qx.getChannel());
					 }
					 for(int i=0;i<channellist.size();i++)
					 {Channel channel=(Channel)channellist.get(i);
					 %> 
					  
					   tree.nodes["1_<%=channel.getChannelId()%>"] = "text:<%=channel.getName().replaceAll("'","‘").replaceAll("\"","”")%>;method:sa('<%=channel.getChannelId()%>','<%=channel.getName().replaceAll("'","‘").replaceAll("\"","”")%>')";  
					 <%
					   }
					 %>
					 
				   tree.setTarget("MzMain");
				   document.write(tree.toString());    //亦可用 obj.innerHTML = tree.toString();
				 </script>
				 <%} %>
	</div>
	
	
<body>
 <%
       int newsid = Integer.parseInt(request.getParameter("newsid"));
       NewsDAO newsDao = new NewsDAO();
       News news = new News();
       news = newsDao.findById(newsid);
       Channel channel=news.getChannelid();
       int channelid=news.getChannelid().getChannelId(); 
     %>

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="30"><img src="images/tab_03.gif" width="15" height="30" /></td>
        <td width="1101" background="images/tab_05.gif"><img src="images/311.gif" width="16" height="16" />
			<span class="STYLE4">信息修改页面</span></td>
        <td width="281" background="images/tab_05.gif">
        &nbsp;
        </td>
        <td width="14"><img src="images/tab_07.gif" width="14" height="30" /></td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="9" background="images/tab_12.gif">&nbsp;</td>
        <td bgcolor="#f3ffe3">
        <form name="form1" id="form1" action="<%=request.getContextPath()%>/admin/managerNew.do?method=upNews" enctype="MULTIPART/FORM-DATA" method="post" onSubmit="return CheckForm();" >  
	  <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
          <td width="15%" height="30" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">新闻栏目：</td>
          <td height="30" colspan="3" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:10px" class="STYLE1"><span style="padding-left:7px">
            <input name="lanmuName" id="lanmuName" type="text" value="<%=channel.getName() %>" class="ts_box3" readonly="true">
          </span>
		<input type="button" value="选择栏目" onclick="showlayer()" />
		<input type="hidden" value="<%=channelid %>" id="channelid" name="channelid" />
		<input type="hidden" value="<%=newsid %>" id="newsid" name="newsid" />
		<input type="hidden" value="" id="lei" name="lei"/> 
		  </td>
        </tr>
        <tr>
          <td width="15%" height="30" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">新闻标题：</td>
          <td height="30" colspan="3" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:10px" class="STYLE1"><span style="padding-left:7px">
            <input name="newName" id="newName" maxlength="250" size="50" type="text" value="<%=news.getTitle() %>">
          </span></td>
        </tr>
        
        <tr>
        
         <td width="15%" height="30" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">
				发布时间：
			</td>
			<td height="30" align="left" valign="middle" colspan="3" bgcolor="#FFFFFF" style="padding-left:10px" class="STYLE1"><span style="padding-left:7px">
			<input name="date" id="date" class="Wdate"
				type="text" size="22" value="<%=news.getAddDate()%>" readonly
				onClick="WdatePicker({skin:'default',dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d'})" />
				</span>
			</td>
        </tr>
	  <tr>
				<td  bgcolor="#FFFFFF" align="center" class="STYLE1">发布人：</td>
				<td  bgcolor="#FFFFFF" style="padding-left:17px" class="STYLE1"><input type="text" value="<%=news.getPublisher() %>" name="fbr" ><font color="red">*</font>
	审核人：<input type="text" name="shr" value="<%=news.getReviewed() %>" ><font color="red">*</font>
				</td>
				
	
			</tr>
        <tr>
          <td height="320" colspan="4" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">
		  <FCK:editor id="content" basePath="/admin/fckeditor/" height="400" imageBrowserURL="/admin/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
			linkBrowserURL="/admin/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
			flashBrowserURL="/admin/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
			imageUploadURL="/admin/fckeditor/editor/filemanager/upload/simpleuploader?Type=Image"
			linkUploadURL="/admin/fckeditor/editor/filemanager/upload/simpleuploader?Type=File"
			flashUploadURL="/admin/fckeditor/editor/filemanager/upload/simpleuploader?Type=Flash">
		<%=news.getContent() %>
		</FCK:editor>
		  </td>
        </tr>
        <tr>
          <td width="15%" height="30" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">上传图片：</td>
           
          <td height="30" colspan="3" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:10px" class="STYLE1"><span style="padding-left:7px">
            <%if(news.getImg()!=null)
        	  {if(!news.getImg().equals(""))
        	  {%>
        	  
                   <img src="../<%=news.getImg() %>" style="max-width:60px;width: expression(this.width > 60 ? 60: true);">
                   <input type="checkbox" name="delPic" value="1">删除
        	  <% }}%>
           
           <input type="file" name="pics" id="pics"/>
          </span></td>
        
        	  

        </tr>
        <tr>
          <td width="15%" height="30" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">链接文件：</td>
          <td class="STYLE1" height="30" colspan="3" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:10px"><span style="padding-left:7px">
            <%if(news.getFilePath()!=null)
        	  {if(!news.getFilePath().equals(""))
        	  {%>
        	  
                   <a href="../<%=news.getFilePath() %>" target="_blank"><%=news.getFilePath().substring(news.getFilePath().lastIndexOf("/")+1)%></a>
        	  <input type="checkbox" name="delFile" value="1">删除
        	  <% }}%>
           <input type="file" name="files" id="files" />
          </span>
          </td>
        </tr>
	    <tr>
			 <td width="15%" height="30" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">内容附件：</td>
			 <td bgcolor="#FFFFFF" class="STYLE1" style="padding-left:17px"><INPUT type="hidden" name="attachment" id="attachment" value="">					 
				<iframe name="upload" id="upload" src="selectFile.jsp?field=attachment" width="100%" height="100" scrolling="yes" frameborder="0"></iframe>	
			 </td>
		</tr>
    	<tr>
			 <td width="15%" height="30" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1">现有附件：</td>
			 <td bgcolor="#FFFFFF" class="STYLE1" style="padding-left:17px">
					<%
						if(news.getAttachment()!=null && !news.getAttachment().equals(""))
						{
							String [] attach=news.getAttachment().split(";");
							int i=1;
							for(String attachment:attach)
							{
								%>
								<%=attachment.substring(attachment.lastIndexOf("/")+1)%><input type="checkbox" value="<%=attachment%>" name="delAttachment">删除
								<br>
								<%
							}
						}
					%>
			 </td>
		</tr>
       
        <tr>
          <td height="30" colspan="4" align="center" valign="middle" bgcolor="#FFFFFF" class="STYLE1"><span style="padding-left:7px">
           <input type="submit" value="提交" />
		   <input type="button" onclick="location.href='tree.jsp'" value="返回" />
          </span></td>
        </tr>
      </table>
</form>
        </td>
        <td width="9" background="images/tab_16.gif">&nbsp;</td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td height="29">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="29"><img src="images/tab_20.gif" width="15" height="29" /></td>
        <td background="images/tab_21.gif">
        &nbsp;</td>
        <td width="14"><img src="images/tab_22.gif" width="14" height="29" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<script type="text/javascript">
var message = "<%=session.getAttribute("message")%>";
if(message!=null && message!="null" && message !=""){
   alert(message);
  }
</script>
<%
	session.removeAttribute("message");
%>